//
//  CenterPageC.m
//  UniverseProject
//
//  Created by king on 2021/6/22.
//  Copyright © 2021 Cloud2209. All rights reserved.
//

#import "DemoC1.h"
#import "CenterPageC.h"
#import <JXCategoryView.h>

@interface CenterPageC ()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate>

@property (nonatomic, strong)JXCategoryTitleView *categoryView;
@property (nonatomic, strong) JXCategoryListContainerView *listContainerView;//listView

@end

@implementation CenterPageC

- (void)viewDidLoad {
    [super viewDidLoad];
   
    CGFloat categoryViewH = 50;
    
    self.categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, 0, K_SCREEN_WIDTH, categoryViewH)];
    self.categoryView.delegate = self;
    [self.view addSubview:self.categoryView];
        
    self.categoryView.titles = @[@"螃蟹", @"麻辣小龙虾", @"苹果"];
    self.categoryView.titleColorGradientEnabled = YES;
    self.categoryView.titleSelectedColor = LGCOLOR(@"663377");
    self.categoryView.titleFont = LGFONT(14);
    self.categoryView.titleSelectedFont = LGFONT(18);
   
    JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
    lineView.indicatorColor = [UIColor redColor];
    lineView.indicatorWidth = JXCategoryViewAutomaticDimension;
    self.categoryView.indicators = @[lineView];
    
//    self.listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
//    self.listContainerView.frame = CGRectMake(0, k_StatusBarHeight + categoryViewH, K_SCREEN_WIDTH, K_SCREEN_HEIGHT - k_StatusBarHeight - categoryViewH);
//    [self.view addSubview:self.listContainerView];
//    //关联到categoryView
//    self.categoryView.listContainer = self.listContainerView;
    
    
}

//代理JXCategoryViewDelegate
-(void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
//侧滑手势处理
self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
//NSLog(@"%@", NSStringFromSelector(_cmd));
}

-(void)categoryView:(JXCategoryBaseView *)categoryView didScrollSelectedItemAtIndex:(NSInteger)index {
//NSLog(@"%@", NSStringFromSelector(_cmd));
}

//5、代理JXCategoryListContainerViewDelegate

-(id)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
    DemoC1 *list = [[DemoC1 alloc] init];
    if (index == 0) {
        list.view.backgroundColor = [UIColor redColor];
    }else{
        list.view.backgroundColor = [UIColor blueColor];
    }
    return list;
}

-(NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
    return 3;
}

@end
